package org.springblade.modules.enterprise.wrapper;

import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.SpringUtil;
import org.springblade.modules.enterprise.entity.Enterprise;
import org.springblade.modules.enterprise.vo.EnterpriseVO;
import org.springblade.modules.system.service.IDictItemService;

public class EnterpriseWrapper extends BaseEntityWrapper<Enterprise, EnterpriseVO> {

	private static IDictItemService dictItemService;

	static {
		dictItemService = SpringUtil.getBean(IDictItemService.class);
	}

	public static EnterpriseWrapper build() {
		return new EnterpriseWrapper();
	}

	@Override
	public EnterpriseVO entityVO(Enterprise enterprise) {
		EnterpriseVO enterpriseVO = BeanUtil.copy(enterprise, EnterpriseVO.class);
		if (Func.isNotEmpty(enterprise.getEnterpriseNature())) {
			String objectQualityName = dictItemService.getLabel("OBJECT_QUALITY", enterprise.getEnterpriseNature());
			enterpriseVO.setObjectQualityName(objectQualityName);
		} else {
			enterpriseVO.setObjectQualityName("");
		}
		return enterpriseVO;
	}
}
